<extend name="Index/index" />

<block name="main">
<div id="tou">
    <li>
        <i class="icon-home home-icon"></i>
        <a href="<{:U('Index/index')}>">首页</a>
    </li>
    <li>》</li>
    <li class="active">后台用户添加</li>
</div>
<br>

	<div class="row">
		<div class="col-md-12">
			<form action="<{:U('AdminUser/doadd')}>" method='post' class="form-horizontal" name="getForm">

				<div class="form-group" style="">
					<label for="" class="col-sm-2 control-label">用户名：</label>
					<div class="col-sm-4">
						<input type="text" name="name" class="form-control" placeholder="用户名">
					</div>
						<span class="yhm" placeholder="请输入用户名"></span>
				</div>
				<!-- 密码 -->
				<div class="form-group">
					<label for="" class="col-sm-2 control-label">密  码 ：</label>
					<div class="col-sm-4">
						<input type="password" name="pwd" class="form-control" placeholder="请输入密码">
					</div>
					<span class="mima"></span>
				</div>
				<!-- 确认密码 -->
				<div class="form-group">
					<label for="" class="col-sm-2 control-label">确认密码：</label>
					<div class="col-sm-4">
						<input type="password" name="tpwd" class="form-control" placeholder="请输入相同的密码">
					</div>
					<span class="mima1"></span>
				</div>
				<div class="form-group">
				    <div class="col-sm-offset-2 col-sm-4">
				      <button type="submit" class="btn btn-success">添 加</button>
				    </div>
				</div>
		
			</form>
		</div>
	</div>
	 <script src="__PUBLIC__/js/jquery.min.js"></script>
     <script>
        $(function(){
            //验证用户名
            var number = document.getForm.name;
            number.onblur = num;
                function num(){
                      var number1 = document.getForm.name.value;
                      if (number1.match(/^\w{4,12}$/) == null) {
                           $(' .yhm').css('color','red').html('用户名为4-12位字符');
                            return false;
                        }else{
                            $(' .yhm').css('color','red').html('');
                             return true;
                        }
               }

            var tpwd = document.getForm.tpwd;
            console.log(tpwd);
            tpwd.onblur = tpwdd;
              function tpwdd(){
               var pwd1 = document.getForm.pwd.value;
               var pwd2 = document.getForm.tpwd.value;
               console.log	(pwd1);
                 if (pwd1!=pwd2) {
                           $(' .mima1').css('color','red').html('请输入相同密码');
                            return false;
                        }else{
                           $(' .mima1').css('color','red').html('');
                            return true;
                        }
               }

              var pwd = document.getForm.pwd;
            	pwd.onblur = pwdd;
               function pwdd(){
                var pwd1 = document.getForm.pwd.value;
                 if (pwd1.length < 6 || pwd1.length >18) {
                           $(' .mima').css('color','red').html('密码为6-18位字符');
                            return false;
                        }else{
                           $(' .mima').css('color','red').html('');
                            return true;
                        }
               }


            $('#tab-add form').submit(function(){
                    return num() && pwdd()&& tpwdd();
            })
        })
    </script>
</block>